package com.lxk.vo.result;

/**
 * @author JohnSoybean
 * @create 2020/3/19 15:54
 * @description 状态码及错误信息工具类
 */
public class CodeMsg {
    private Integer code;
    private String msg;

    private CodeMsg() {
    }
    private CodeMsg(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    //通用的错误码
    public static CodeMsg SUCCESS = new CodeMsg(0, "success");
    public static CodeMsg SERVER_ERROR = new CodeMsg(500100, "服务端异常");
    public static CodeMsg BIND_ERROR = new CodeMsg(500101, "参数校验异常：%s");
    public static CodeMsg REQUEST_ILLEGAL = new CodeMsg(500102, "请求非法");
    public static CodeMsg ACCESS_LIMIT_REACHED= new CodeMsg(500104, "访问太频繁！");
    public static CodeMsg NULL_POINTER= new CodeMsg(500105, "空指针异常");
    public static CodeMsg MYSQL_CRUD_FAIL= new CodeMsg(500106, "数据库操作异常");
    public static CodeMsg PARAM_ABSENCE = new CodeMsg(500107, "缺少需要的参数");
    public static CodeMsg INFO_NOT_EXIST = new CodeMsg(500108, "该信息不存在");
    public static CodeMsg NO_HANDLER_FOUND =  new CodeMsg(500109, "404不存在");

    //管理员账号模块 5002XX
    public static CodeMsg PASSWORD_ERR = new CodeMsg(500200, "密码错误");
    public static CodeMsg ADMIN_NOT_EXIST = new CodeMsg(500201, "账号不存在");
    public static CodeMsg PWD_NOT_SAME = new CodeMsg(500201, "新密码两次输入不一致");

    //商品模块 5003XX
    public static CodeMsg INVALID_LNGLAT = new CodeMsg(500300, "经纬度错误");
    public static CodeMsg SHIFT_UPPER_ERROR = new CodeMsg(500301, "商品上下架出错");
    public static CodeMsg ADD_GOODS_ERROR = new CodeMsg(500302, "添加商品出错");
    public static CodeMsg EMPTY_GOODS_ADDR = new CodeMsg(500303, "商品地址不能为空");
    public static CodeMsg NO_SUCH_GOODS = new CodeMsg(500304, "没有该商品");
    public static CodeMsg CHANGE_STOCK_FAIL = new CodeMsg(500305, "更改库存及销量失败");
    public static CodeMsg NO_GOODS_STAT = new CodeMsg(500306, "商品状态不存在");

    //商家模块 5004XX
    public static CodeMsg ADD_SHOP_ERROR = new CodeMsg(500400, "添加商家失败");
    public static CodeMsg DEL_SHOP_ERROR = new CodeMsg(500401, "删除商家失败");
    public static CodeMsg SHOP_NOT_EXIST = new CodeMsg(500402, "店铺不存在");

    //订单模块 5005XX
    public static CodeMsg ORDER_NOT_EXIST = new CodeMsg(500500, "订单不存在");
    public static CodeMsg ORDER_NO_COMMENT = new CodeMsg(500500, "订单未评论");

    //活动模块 5005XX
    public static CodeMsg AUCTION_TIME_ERROR = new CodeMsg(500600, "拍卖时间设置错误");
    public static CodeMsg SECKILL_TIME_ERROR = new CodeMsg(500601, "秒杀时间设置错误");
    public static CodeMsg GOODS_NO_ACTIVITY = new CodeMsg(500602, "当前商品未参与活动");
    public static CodeMsg SECKILL_NOT_EMPTY = new CodeMsg(500603, "只能存在一个秒杀商品，请先取消当前秒杀，再进行设置！");
    public static CodeMsg AUCTION_NOT_EMPTY = new CodeMsg(500604, "只能存在一个拍卖商品，请先取消当前拍卖，再进行设置！");
    public static CodeMsg GOODS_STAT_REPEAT = new CodeMsg(500605, "不能重复设置商品活动，或与其他活动冲突");
    public static CodeMsg WRONG_PRICE = new CodeMsg(500605, "设置了错误的金额");


    //申请模块 5008XX
    public static CodeMsg WXPAY_CONFIG_ERR = new CodeMsg(500800, "初始化支付配置失败");
    public static CodeMsg REFUND_ERROR = new CodeMsg(500801, "发起退款申请失败，原因为：%s");
    public static CodeMsg NO_REFUND_ORDER = new CodeMsg(500802, "退款申请不存在");
    public static CodeMsg CASHOUT_NOT_EXIST = new CodeMsg(500501, "提现申请不存在");

    //文件上传模块 5009XX
    public static CodeMsg UPLOAD_IMAGE_FAIL = new CodeMsg(500900, "上传图片至OSS服务器失败");
    public static CodeMsg UPLOAD_VEDIO_FAIL = new CodeMsg(500901, "上传视频至OSS服务器失败");
    public static CodeMsg IMAGE_SIZE_OUT = new CodeMsg(500902, "图片大小超过10M");
    public static CodeMsg VEDIO_SIZE_OUT = new CodeMsg(500903, "视频大小超过50M");
    public static CodeMsg FILE_IO_ERROR = new CodeMsg(500904, "文件读写错误");
    public static CodeMsg FILE_TYPE_ERROR = new CodeMsg(500905, "文件类型错误: %s");
    public static CodeMsg EMPTY_FILE = new CodeMsg(500906, "图片文件不能为空");



    public Integer getCode() {
        return code;
    }

    public String getMsg() {
        return msg;
    }

    public CodeMsg fillArgs(String message) {
        this.msg = String.format(this.msg, message);
        return this;
    }
}
